package pers.qianyu.month_202101.date_20210131;

/**
 * 第 226 场周赛 第 1 题
 * 5654. 盒子中小球的最大数量
 * https://leetcode-cn.com/problems/maximum-number-of-balls-in-a-box/
 *
 * @author mizzle rain
 * @date 2021-01-31 14:47
 */
public class CountBalls {
    public int countBalls(int lowLimit, int highLimit) {
        int[] map = new int[50];
        int res = 1;
        for (int i = lowLimit; i <= highLimit; i++) {
            int s = 0, t = i;
            while (t > 0) {
                s += t % 10;
                t /= 10;
            }
            map[s]++;
            res = Math.max(res, map[s]);
        }
        return res;
    }
}
